import { Button, Radio, Space, Table } from 'antd';
import { useState, useEffect } from 'react'
import _ from 'lodash';
import LittleTitle from '../../../../../../../common/LittleTitle';
import DetailList from '../../../common/JudgeAnalysis/DetailList';
import useMap from '../../../hooks/useMap';


export default function ZzfxfxResult(props) {
    const { result } = props;
    const map = useMap();
    return <div style={{
        padding: '0 12px'
    }}>
        <LittleTitle>分析概要</LittleTitle>
        <div style={{ margin: "8px 0 16px 0" }}>
            <div>
                该区域共有致灾<span style={{
                    fontWeight: 'bold',
                    color: '#f50',
                    padding: '0 3px'
                }}>
                    {_.sumBy(result.data, 'count')}
                </span>处
            </div>
        </div>
        <LittleTitle>结果详情</LittleTitle>
        <Space direction='vertical' style={{
            marginTop: 8,
            width: '100%'
        }}>
            <Table bordered size='samll' dataSource={result?.data}
                columns={[
                    {
                        title: '类型',
                        dataIndex: 'yhlx',
                        width: 160,
                        ellipsis: true
                    }, {
                        title: '数量',
                        dataIndex: 'count',
                        align: 'center'
                    },
                    {
                        width: 80,
                        align: 'center',
                        render: (a, record) => {
                            return <Button type="link" size='small' onClick={() => {
                                map.dispatchEvent({
                                    type: 'detail.show2',
                                    title: record.yhlx,
                                    component: <DetailList type="yh" yhlx={record.yhlx} wkt={result.wkt} />
                                })
                            }}>详情</Button>
                        }
                    }]}
                pagination={{
                    pageSize: 10
                }} />
        </Space>

    </div>;
}